home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / graphic / eedsrc24.zip / EEP24SRC.ZIP / EESTRING.C < prev    next >
C/C++ Source or Header  |  1992-07-29  |  6KB  |  177 lines

  1. /*****************************************************************************
  2. *   Module to handle screen printing.                         *
  3. *                                         *
  4. * Written by:  Gershon Elber            IBM PC Ver 1.0,    Dec. 1989    *
  5. *****************************************************************************/
  6.  
  7. #include <stdio.h>
  8. #include "program.h"
  9. #include "igraph.h"
  10. #include "eestring.h"
  11.  
  12. static void PutTextInfoNoCentering(int PosX, int PosY, char *Str);
  13.  
  14. /*****************************************************************************
  15. * Put out a string, always centered to the given position, with given         *
  16. * orientation, taking into account current zoom factor.                 *
  17. *****************************************************************************/
  18. void PutTextInfo(TextOrientationType Orient, int PosX, int PosY, int Scale,
  19.                                 char *Str)
  20. {
  21.     IGTextFormat(Orient, Scale, TEXT_X_CENTER, TEXT_Y_CENTER);
  22.     IGMoveTo(PosX, PosY);
  23.     IGText(Str);
  24.     IGTextFormat(TEXT_ORIENT_HORIZ, 1, TEXT_X_CENTER, TEXT_Y_CENTER);
  25. }
  26.  
  27. /*****************************************************************************
  28. * Same as PutTextInfo but does no centering.                     *
  29. *****************************************************************************/
  30. static void PutTextInfoNoCentering(int PosX, int PosY, char *Str)
  31. {
  32.     IGMoveTo(PosX, PosY);
  33.     IGText(Str);
  34.     IGTextFormat(TEXT_ORIENT_HORIZ, 1, TEXT_X_CENTER, TEXT_Y_CENTER);
  35. }
  36.  
  37. /*****************************************************************************
  38. * Put out pin number and pin text info, given the pin line coordinates.         *
  39. * The line must be vertical or horizontal.                     *
  40. * If PinNext == NULL nothing is printed. If PinNum = 0 no number is printed. *
  41. * Current Zoom factor is taken into account.                     *
  42. * If TextInside then the text is been put inside (moving from x1, y1 in      *
  43. * the opposite direction to x2, y2), otherwise all is drawn outside.         *
  44. *****************************************************************************/
  45. void PutLineTextInfo(int x1, int y1, int x2, int y2, char *PinText, int PinNum,
  46.                 BooleanType TextInside, BooleanType DrawNums)
  47. {
  48.     int x, y;
  49.     BooleanType IsNot;
  50.     char SPinNum[MAX_PIN_INFO];
  51.  
  52.     /* Do we need to invert the string? Is this string has only "~"? */
  53.     if (PinText != NULL && (IsNot = PinText[0] == '~') != FALSE) {
  54.         PinText++;
  55.     if (PinText[0] == 0) PinText = NULL;
  56.     }
  57.  
  58.     if (TextInside) {  /* Draw the text inside, but the pin numbers outside. */
  59.     if (x1 != x2) {                  /* Its an horizontal line. */
  60.         if (PinText != NULL) {
  61.         if (x1 > x2) {
  62.             IGTextFormat(TEXT_ORIENT_HORIZ, 1,
  63.                  TEXT_X_LEFT, TEXT_Y_CENTER);
  64.             x = x1 + TextInside;
  65.             PutTextInfoNoCentering(x, y1, PinText);
  66.             if (IsNot) {
  67.                     IGDrawNotBar(
  68.                 IGMapX(x),
  69.                 IGMapY(y1) - IGTextHeightNoMap(PinText) / 2 - 2,
  70.                 IGTextWidthNoMap(PinText),
  71.                     0,
  72.                     PinText);
  73.             }
  74.         }
  75.         else {
  76.             IGTextFormat(TEXT_ORIENT_HORIZ, 1,
  77.                  TEXT_X_RIGHT, TEXT_Y_CENTER);
  78.             x = x1 - TextInside;
  79.             PutTextInfoNoCentering(x, y1, PinText);
  80.             if (IsNot) {
  81.                     IGDrawNotBar(
  82.                 IGMapX(x),
  83.                 IGMapY(y1) - IGTextHeightNoMap(PinText) / 2 - 2,
  84.                 -IGTextWidthNoMap(PinText),
  85.                     0,
  86.                     PinText);
  87.             }
  88.         }
  89.         }
  90.         if (PinNum != 0 && DrawNums) {
  91.         IGTextFormat(TEXT_ORIENT_HORIZ, 1,
  92.                  TEXT_X_CENTER, TEXT_Y_BOTTOM);
  93.         sprintf(SPinNum, "%d", PinNum);
  94.         PutTextInfoNoCentering((x1 + x2) / 2, y1 + 1, SPinNum);
  95.         }
  96.     }
  97.     else {                         /* Its a vertical line. */
  98.         if (PinText != NULL) {
  99.         if (y1 > y2) {
  100.             IGTextFormat(TEXT_ORIENT_VERT, 1,
  101.                  TEXT_X_CENTER, TEXT_Y_TOP);
  102.             y = y1 + TextInside;
  103.             PutTextInfoNoCentering(x1, y, PinText);
  104.             if (IsNot) {
  105.                     IGDrawNotBar(
  106.                 IGMapX(x1) - IGTextHeightNoMap(PinText) / 2 - 2,
  107.                 IGMapY(y),
  108.                 0,
  109.                     IGTextWidthNoMap(PinText),
  110.                     PinText);
  111.             }
  112.         }
  113.         else {
  114.             IGTextFormat(TEXT_ORIENT_VERT, 1,
  115.                  TEXT_X_CENTER, TEXT_Y_BOTTOM);
  116.             y = y1 - TextInside;
  117.             PutTextInfoNoCentering(x1, y, PinText);
  118.             if (IsNot) {
  119.                     IGDrawNotBar(
  120.                 IGMapX(x1) - IGTextHeightNoMap(PinText) / 2 - 2,
  121.                 IGMapY(y),
  122.                 0,
  123.                     -IGTextWidthNoMap(PinText),
  124.                     PinText);
  125.             }
  126.         }
  127.         }
  128.         if (PinNum != 0 && DrawNums) {
  129.         IGTextFormat(TEXT_ORIENT_VERT, 1, TEXT_X_RIGHT, TEXT_Y_CENTER);
  130.         sprintf(SPinNum, "%d", PinNum);
  131.         PutTextInfoNoCentering(x1 - 1, (y1 + y2) / 2, SPinNum);
  132.         }
  133.     }
  134.     }
  135.     else {                       /* Draw text outside as well. */
  136.     if (x1 != x2) {                  /* Its an horizontal line. */
  137.         if (PinText != NULL) {
  138.         IGTextFormat(TEXT_ORIENT_HORIZ, 1,
  139.                  TEXT_X_CENTER, TEXT_Y_BOTTOM);
  140.         PutTextInfoNoCentering(x = (x1 + x2) / 2, y1 - 1, PinText);
  141.         if (IsNot) {
  142.                 IGDrawNotBar(
  143.                 IGMapX(x) - IGTextWidthNoMap(PinText) / 2,
  144.             IGMapY(y1) - IGTextHeightNoMap(PinText) - 3,
  145.                 IGTextWidthNoMap(PinText),
  146.             0,
  147.                 PinText);
  148.         }
  149.         }
  150.         if (PinNum != 0 && DrawNums) {
  151.         IGTextFormat(TEXT_ORIENT_HORIZ, 1, TEXT_X_CENTER, TEXT_Y_TOP);
  152.         sprintf(SPinNum, "%d", PinNum);
  153.         PutTextInfoNoCentering((x1 + x2) / 2, y1 + 10, SPinNum);
  154.         }
  155.     }
  156.     else {                         /* Its a vertical line. */
  157.         if (PinText != NULL) {
  158.         IGTextFormat(TEXT_ORIENT_VERT, 1, TEXT_X_RIGHT, TEXT_Y_CENTER);
  159.         PutTextInfoNoCentering(x1 - 2, y = (y1 + y2) / 2, PinText);
  160.         if (IsNot) {
  161.                 IGDrawNotBar(
  162.                 IGMapX(x1) - 11,
  163.             IGMapY(y) - IGTextHeightNoMap(PinText) / 2,
  164.             0,
  165.                 IGTextWidthNoMap(PinText),
  166.                 PinText);
  167.         }
  168.         }
  169.         if (PinNum != 0 && DrawNums) {
  170.         IGTextFormat(TEXT_ORIENT_VERT, 1, TEXT_X_LEFT, TEXT_Y_CENTER);
  171.         sprintf(SPinNum, "%d", PinNum);
  172.         PutTextInfoNoCentering(x1 + 10, (y1 + y2) / 2, SPinNum);
  173.         }
  174.     }
  175.     }
  176. }
  177.